package com.work.keep.fragment;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.toolbox.ImageLoader;
import com.work.keep.R;
import com.work.keep.activity.PlaygroundActivity;
import com.work.keep.activity.RecommendActivity;
import com.work.keep.base.BaseFragment;
import com.work.keep.volley.GsonRequest;
import com.work.keep.volley.VolleySingleton;

/**
 * https://api.gotokeep.com/v1.1/home/dashboard/statistics
 * Created by dllo on 16/1/19.
 */
public class UserTrainingFragment extends BaseFragment {
    private Context context;
    private VolleySingleton volleySingleton;
    private ImageView userToTraining;
    private ImageLoader imageLoader;
    private TextView trainTimeTV, mfinish, myTotalTime, myCalorie, myRanking;
    private RelativeLayout trainingReference, allTrainings;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_user, container, false);
        return v;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        userToTraining = (ImageView) view.findViewById(R.id.userToTraining);
        trainTimeTV = (TextView) view.findViewById(R.id.trainTimeTV);
        mfinish = (TextView) view.findViewById(R.id.mfinish);
        myTotalTime = (TextView) view.findViewById(R.id.myTotalTime);
        myCalorie = (TextView) view.findViewById(R.id.myCalorie);
        myRanking = (TextView) view.findViewById(R.id.myRanking);
        trainingReference = (RelativeLayout) view.findViewById(R.id.trainingReference);
        allTrainings = (RelativeLayout) view.findViewById(R.id.allTrainings);
    }

    @Override
    protected void init() {
        volleySingleton = VolleySingleton.getInstance();
        imageLoader = volleySingleton._getImageLoader();
        trainingReference.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RecommendActivity.goToRecommendActivity(context);
            }
        });
        userToTraining.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PlaygroundActivity.goToPlaygroundActivity(context);
            }
        });
//        GsonRequest<>
    }
}
